package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.pojo.ReserveInfor;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private OrderService orderService;

    //用户预约套餐
    @PostMapping("/submit.do")
    public Result orderInfor(@RequestBody ReserveInfor reserveInfor) {
        //首先判断验证码是否正确
        HttpSession session = request.getSession();
        String validateCode = (String) session.getAttribute(reserveInfor.getTelephone());
        if (!validateCode.equals(reserveInfor.getValidateCode())) {
            return new Result(false, "验证码输入错误");
        }
      return orderService.orderInfor(reserveInfor);
}
//查询套餐信息
    @PostMapping("/findById.do")
    public Result findById(Integer id){
      return


              orderService.findById(id);
    }


}
